/*
 * Copyright 2006-2008 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.martinimix.domain.account;

import java.io.Serializable;

/**
 * Provides a customer phone number
 * 
 * @author Scott Rossillo
 *
 */
public class PhoneNumber implements Serializable {

	private static final long serialVersionUID = 1L;
	
	private String areaCode;
	private String prefix;
	private String number;
	
	/**
	 * Creates a new phone number.
	 */
	public PhoneNumber() {
		super();
	}
	
	/**
	 * Creates a new phone code as a copy of the
	 * given other phone number.
	 * 
	 * @param other the <code>PhoneNumber</code> to copy
	 */
	public PhoneNumber(final PhoneNumber other) {
		this();
		this.areaCode = other.areaCode;
		this.prefix = other.prefix;
		this.number = other.number;
	}
	
	public String getAreaCode() {
		return areaCode;
	}
	public void setAreaCode(String areaCode) {
		this.areaCode = areaCode;
	}
	public String getPrefix() {
		return prefix;
	}
	public void setPrefix(String prefix) {
		this.prefix = prefix;
	}
	public String getNumber() {
		return number;
	}
	public void setNumber(String number) {
		this.number = number;
	}
	
	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		
		StringBuffer b = new StringBuffer(20);
		
		if(areaCode != null) {
			b.append(areaCode).append('-');
		}
	
		if(prefix != null) {
			b.append(prefix).append('-');	
		}
		
		if(number != null) {
			b.append(number);
		}
		
		return b.toString().trim();
	}

}
